// Copyright 2010 The Go Example Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
	"fmt"
	"os"
)

func main() {

	fileName := "data/hello.txt"
	//open file
	file, err := os.Open(fileName, os.O_RDONLY, 0)
	if file == nil {
		fmt.Printf("can't open file; err=%s\n", err.String())
		os.Exit(1)
	}

	//Clode file
	defer file.Close()

	for { //byte buffer
		var buff [128]byte
		//read data
		i, e := file.Read(buff[:])

		if e == os.EOF {
			break
		}

		content := string(buff[0:i])
		fmt.Print(content)

		fmt.Sprintln(buff)
	}
}
